<#assign ctx=springMacroRequestContext.contextPath />
<#include "/macro/publicMacro.ftl">
<#import "/macro/pagination.ftl" as Pagination>

<@header title="Log列表">
    <link href="${ctx}/resource/common/css/pagination.css" rel="stylesheet">
    <script src="${ctx}/resource/common/js/pagination.js"></script>
    <link href="${ctx}/resource/frame/datetimepicker/jquery.datetimepicker.min.css" rel="stylesheet">
</@header>

<@body>
    <h2 class="module-title">Log管理</h2>

    <div class="alert alert-primary" role="alert">
        <form id="logSearchForm" class="form-inline form-margin" action="${ctx}/log/list">
            <div class="form-group mx-sm-3 mb-2">
                <label for="managerUser.id" class="ml-2" >操作人：</label>
                <input type="text" class="form-control" id="managerUser.id" name="managerUser.id" value="${log.managerUser.id}" style="max-width: 80px">
            </div>
            <div class="form-group mx-sm-3 mb-2">
                <label for="user.id"  class="ml-2">被操作人：</label>
                <input type="text" class="form-control" id="user.id" name="user.id" value="${log.user.id}" style="max-width: 80px">
            </div>
            <div class="form-group mx-sm-3 mb-2">
                <label for="type"  class="ml-2">操作类型：</label>
                <select name="type" class="form-control">
                    <option value="">请选择</option>
                    <#list logTypes as logType>
                        <option value="${logType}" <#if logType == log.type>selected</#if>>${logType.desc}</option>
                    </#list>
                </select>
            </div>
            <div class="form-group mx-sm-3 mb-2">
                <label for="module-name" class="ml-2">租户名称：</label>
                <select class="form-control" name="tenantId" id="tenantId">
                    <#list tenants as tenant>
                        <option value="${tenant.id}" <#if tenant.id == cmsArticle.tenantId>selected</#if>>${tenant.description}</option>
                    </#list>
                </select>
            </div>
<#--            <div class="input-group date form-group mx-sm-3 mb-2">-->
<#--                <label for="startCreateTime" class="ml-2">开始时间：</label>-->
<#--                <input type="text" class="form-control" name="startCreateTime" id="startCreateTime" aria-describedby="创建时间" value="${(log.startCreateTime?string('yyyy-MM-dd'))!}" autocomplete="off" style="max-width: 110px">-->
<#--                <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>-->
<#--            </div>-->
<#--            <div class="form-group mx-sm-3 mb-2">-->
<#--                <label for="endCreateTime" class="ml-2">结束时间：</label>-->
<#--                <input type="text" class="form-control" name="endCreateTime" id="endCreateTime" aria-describedby="创建时间" value="${(log.endCreateTime?string('yyyy-MM-dd'))!}" autocomplete="off" style="max-width: 110px">-->
<#--                <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>-->
<#--            </div>-->

            <div class="form-group mx-sm-3 mb-2">
                <button type="submit" class="btn btn-primary">查询</button>
            </div>
        </form>
    </div>

    <div class="table-responsive">
        <table class="table table-striped table-bordered">
            <thead>
                <th>主键</th>
                <th>操作人</th>
                <th>被操作人</th>
                <th>操作类型</th>
                <th>操作介绍</th>
                <th>ip</th>
                <th>创建时间</th>
                <th>操作</th>
            </thead>
            <tbody>
            <#list logs.beans as log>
                <tr>
                    <td>${log.id!}</td>
                    <td>${log.managerUser.nickName!}<#if log.managerUser??>(${log.managerUser.id!})</#if></td>
                    <td>${log.user.nickName!}<#if log.user??>(${log.user.id!})</#if></td>
                    <td>${log.type!}</td>
                    <td>${log.content!}</td>
                    <td>${log.ip!}</td>
                    <td>${(log.createTime?string('yyyy-MM-dd hh:mm:ss'))!} </td>
                    <td><@shiro.hasPermission name="log:view"><a class="btn btn-primary btn-sm" href="${ctx}/log/view/${log.id?c}" role="button" aria-pressed="true">详情</a></@shiro.hasPermission>
                    </td>
                </tr>
            </#list>
            </tbody>
        </table>

        <@Pagination.pagination formId="logForm"
            pageNo=logs.pageNo
            pageTotal=logs.pageTotal
            total=logs.total
            pageSize=logs.pageSize
            action="${ctx}/log/list">
            <input type="hidden" name="managerUser.id" value="${log.managerUser.id}"/>
            <input type="hidden" name="user.id" value="${log.user.id}"/>
            <input type="hidden" name="user.id" value="${log.user.id}"/>
            <input type="hidden" name="type" value="${log.type}"/>
            <input type="hidden" name="module.id" value="${log.module.id}"/>
            <input type="hidden" name="startCreateTime" value="${log.startCreateTime}"/>
            <input type="hidden" name="endCreateTime" value="${log.endCreateTime}"/>
        </@Pagination.pagination>
    </div>
</@body>

<@footer>
    <script src="${ctx}/resource/common/js/jquery.validate.min.js"></script>
    <script src="${ctx}/resource/frame/datetimepicker/jquery.datetimepicker.full.min.js"></script>

    <script>
        $(function () {
            $('#startCreateTime').datetimepicker({
                format:'Y-m-d',
                lang:'zh'});

            $('#endCreateTime').datetimepicker({
                format:'Y-m-d',
                lang:'zh'});
        });

        $("#logSearchForm").validate({
            rules: {
                'managerUser.id': "digits" ,
                'user.id': "digits"
            }
        });
    </script>
</@footer>